﻿using Dsl.Ped.AddIn.Java.Generated;
using Dsl.Ped.AddIn.Java.Resources;

namespace Dsl.Ped.AddIn.Java.Helpers
{
    /// <summary>
    /// Helper methods of the <see cref="Class"/>
    /// </summary>
    public static class ClassHelper
    {
        /// <summary>
        /// Converts the <see cref="Class"/> object to its plain text representation
        /// </summary>
        /// <param name="javaClass"><see cref="Class"/> object to be converted into a plain text</param>
        /// <returns>String representing a <see cref="javaClass"/> converted to a plain text</returns>
        public static string ToPlainText(this Class javaClass)
        {
            var javaClassStr = string.Format("{0}class{0} {1}", JavaResources.KeyWordsDelimiter, javaClass.name);
            if (!string.IsNullOrEmpty(javaClass.superclass))
            {
                javaClassStr += string.Format(" {0}extends{0} {1}", JavaResources.KeyWordsDelimiter, javaClass.superclass);
            }
            javaClassStr = javaClassStr + " {\r\n" + javaClass.members.ToPlainText(javaClass.name, 1) + "\r\n}";

            return javaClassStr;
        }
    }
}
